package com.x.Part12_Object.toStringApply;

import com.x.Part12_Object.User;

import java.io.File;
import java.util.Date;

/**
 * ClassName: toStringTest
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2024.02.29 22:24
 */
public class toStringTest {
    public static void main(String[] args) {
        User u1 = new User("hx",27);
        System.out.println(u1.toString());//打印的是u1引用的地址值
        System.out.println(u1);//与上一样是地址值
        //在User里重写了toString(),输出对象的实体内容User{name:hx, age:27}

        System.out.println("**********");

        Date date = new Date();
        System.out.println(date);
        System.out.println(date.toString());

        System.out.println("**********");

        File file =new File("D:\\a.txt");
        System.out.println(file);
        System.out.println(file.toString());

        //以上没有输出地址值是因为toString()方法重写了，包括String、File、Date、包装类
    }
}
